#include "../include/heat.hpp"
#include "../include/json.hpp"

using namespace std;
using namespace Eigen;
using json = nlohmann::json;

json openfile()
{
    ifstream file("./input/input.json");
    if (!file.is_open())
        cerr << "Failed to open file" << endl;
    json j;
    file >> j;
    file.close();
    return j;
}

enum method
{
    FTCS,
    leapfrog,
    Lax_Friedrichs,
    Lax_Wendorff,
    upwind,
    Beam_Warming
};

int main()
{
    json input = openfile();
    heat_equ he(input["r"]);
    if (input["Method"] == 0)
        he.FTCS();
    else if (input["Method"] == 1)
        he.crank_nicolson();
    else if (input["Method"] == 2)
        he.BTCS();
    else if (input["Method"] == 3)
        he.gauss_legendre();
    else if (input["Method"] == 4)
        he.collocation();
    he.plot(input["index"]);
    return 0;
}